package com.zhuiyun.project.api.sysmenu.controller;

import com.zhuiyun.project.annotation.OptLog;
import com.zhuiyun.project.api.sysmenu.model.SysMenuModel;
import com.zhuiyun.project.api.sysmenu.service.SysMenuService;
import com.zhuiyun.project.common.errorCode.CommonException;
import com.zhuiyun.project.common.response.CommonResult;
import com.zhuiyun.project.util.constants.CommonConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName SysMenuController
 * @Description TODO
 * @Author lzy
 * @Date 2023/5/20 9:52
 **/
@RestController
@CrossOrigin
@RequestMapping("/sysMenu")
@Api(tags = "菜单管理")
@Slf4j
public class SysMenuController {

    @Autowired
    SysMenuService sysMenuService;

    /**
    * @Description 获取菜单列表
    * @Author lzy
    * @Date 2023/5/20 9:59
    * @Return com.hb.lottery.common.response.CommonResult
    */
    @GetMapping("/getMenuByUser")
    @ApiOperation(value = "菜单管理的列表查询方法")
    @OptLog(modular = "菜单管理", type = CommonConstants.SELECT, describe = "菜单查询")
    public CommonResult getMenuList() throws CommonException {
        return sysMenuService.getMenuList();
    }
    
    @GetMapping("/getMenuList")
    @ApiOperation(value = "根据用户查询菜单")
    @OptLog(modular = "菜单管理", type = CommonConstants.SELECT, describe = "根据用户查询菜单")
    public CommonResult getMenuByUser()  {
        return sysMenuService.getMenuByUser();
    }

    /**
    * @Description 菜单管理的菜单新增方法
    * @Author lzy
    * @Date 2023/6/5 15:53
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param sysMenuModel
    */
    @PostMapping("/saveMenu")
    @ApiOperation(value = "菜单管理的菜单新增方法")
    @OptLog(modular = "菜单管理", type = CommonConstants.ADD, describe = "菜单新增")
    public CommonResult saveMenu(@RequestBody SysMenuModel sysMenuModel) throws CommonException {
        return sysMenuService.saveMenu(sysMenuModel);
    }

    /**
    * @Description 菜单管理的菜单修改方法
    * @Author lzy
    * @Date 2023/6/5 15:53
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param sysMenuModel
    */
    @PutMapping("/updateMenu")
    @ApiOperation(value = "菜单管理的菜单修改方法")
    @OptLog(modular = "菜单管理", type = CommonConstants.UPDATE, describe = "菜单修改")
    public CommonResult updateMenu(@RequestBody SysMenuModel sysMenuModel) throws CommonException {
        return sysMenuService.updateMenu(sysMenuModel);
    }

    /**
    * @Description 菜单管理的菜单删除方法
    * @Author lzy
    * @Date 2023/6/5 15:53
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param id
    */
    @DeleteMapping("/deleteMenu")
    @ApiOperation(value = "菜单管理的菜单删除方法")
    @OptLog(modular = "菜单管理", type = CommonConstants.DELETE, describe = "菜单删除")
    public CommonResult deleteMenu(Integer id ) throws CommonException {
        return sysMenuService.deleteMenu(id);
    }

    /**
    * @Description 菜单管理的菜单描述查重方法
    * @Author lzy
    * @Date 2023/6/5 16:58
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param title
    */
    @GetMapping("/checkMenuTitle")
    @ApiOperation(value = "菜单管理的菜单描述查重方法")
    @OptLog(modular = "菜单管理", type = CommonConstants.SELECT, describe = "菜单描述查重")
    public CommonResult checkMenuTitle(String title) throws CommonException {
        return sysMenuService.checkMenuTitle(title);
    }

    /**
    * @Description 菜单管理的菜单url路径查重方法
    * @Author lzy
    * @Date 2023/6/5 16:58
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param url
    */
    @GetMapping("/checkMenuUrl")
    @ApiOperation(value = "菜单管理的菜单url路径查重方法")
    @OptLog(modular = "菜单管理", type = CommonConstants.SELECT, describe = "菜单url路径查重")
    public CommonResult checkMenuUrl(String url) throws CommonException {
        return sysMenuService.checkMenuUrl(url);
    }

    /**
    * @Description 菜单管理的菜单url路径查重方法
    * @Author lzy
    * @Date 2023/6/5 16:58
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param name
    */
    @GetMapping("/checkMenuName")
    @ApiOperation(value = "菜单管理的菜单name查重查重方法")
    @OptLog(modular = "菜单管理", type = CommonConstants.SELECT, describe = "菜单name查重")
    public CommonResult checkMenuName(String name) throws CommonException {
        return sysMenuService.checkMenuName(name);
    }

    /**
    * @Description 菜单管理的菜单url路径查重方法
    * @Author lzy
    * @Date 2023/6/5 16:58
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param curl
    */
    @GetMapping("/checkMenuCurl")
    @ApiOperation(value = "菜单管理的菜单views下的文件路径查重方法")
    @OptLog(modular = "菜单管理", type = CommonConstants.SELECT, describe = "菜单views下的文件路径查重")
    public CommonResult checkMenuCurl(String curl) throws CommonException {
        return sysMenuService.checkMenuCurl(curl);
    }






}
